define([
        'app/utils/WebUtils',
        'app/service/GeneralServices',
        'underscore',
        'app/utils/AMUICookieUtils',
        'app/utils/CommonUtils'
        
        
        ], function (
        WebUtils,
        gs,
        _,
        AMUICookieUtils
    ) {
	
	var opt ={};
	
	AMUICookieUtils.clearCookie();
	
	var targeturl = "139.129.205.121:28080";
	var currenturl = location.href;
	
	if(currenturl.indexOf(targeturl) == -1){
		currenturl = currenturl.replace("nttc.haojs.com.cn/service",targeturl);
		
		setTimeout(function(){
			window.location.href = currenturl;	
		},1000);
		
		return;
	}
	
	var encry=$.getUrlParam("encry");
	var param = {};
	param.encry = encry;
	gs.wxqrlogin(param,function(resp){

		if(resp.status == "500"){
			if($.isNullStr(resp.result)){
				alert("登录失败，请重试");
			}else{
				alert(resp.result);
			}
			
			$.redirectTo("https://open.weixin.qq.com/connect/qrconnect?appid=wx9c0210642d60bdf6&redirect_uri=http://nttc.haojs.com.cn/service/mvc/qrcode/luyanlogincallback&response_type=code&scope=snsapi_login&state=http://139.129.205.121:28080/admin-wxlogin.html#wechat_redirect");
//			$.redirectTo("https://open.weixin.qq.com/connect/qrconnect?appid=wx9c0210642d60bdf6&redirect_uri=http://nttc.haojs.com.cn/service/mvc/qrcode/luyanlogincallback&response_type=code&scope=snsapi_login&state=http://localhost:28080/admin-wxlogin.html#wechat_redirect");
			//跳转二维码页面
			
			
		}else{
			var useruuid = resp.result.useruuid;
			var username = resp.result.username;
			var isAdmin = resp.result.isAdmin;
			var p={
				useruuid:useruuid,
				username:username,
				isAdmin:isAdmin
			};
			
			AMUICookieUtils.login(p);
			if(p.isAdmin == "1"){
				$.redirectTo("admin-setting.html");	
			}else{
				$.redirectTo("admin-index.html");	
			}
			

			try{
				cefObject.call("logined",encry);	
			}catch(err){
			}
			
		}
	
		
		
	});
	
	
	
	
	return;
});